HA$PBExportHeader$u_cst_mmovimiento_salida.sru
forward
global type u_cst_mmovimiento_salida from u_cst_mantocabedet
end type
end forward

global type u_cst_mmovimiento_salida from u_cst_mantocabedet
end type
global u_cst_mmovimiento_salida u_cst_mmovimiento_salida

type variables
long il_documento
boolean ib_printGrabar=false
string is_alma,is_criterio
end variables

forward prototypes
public subroutine of_setparm (integer ai_parm1, integer ai_parm2, integer ai_parm3)
public function string of_gettdocumento ()
public function boolean of_verificar_datos_detalle ()
public subroutine of_retrieve (long al_codigo)
end prototypes

public subroutine of_setparm (integer ai_parm1, integer ai_parm2, integer ai_parm3);istr_parm.integer_parm[1]=ai_parm1
istr_parm.integer_parm[2]=ai_parm2
istr_parm.integer_parm[3]=ai_parm3
end subroutine

public function string of_gettdocumento ();string ls_documento
ls_documento = space(14)
sqlca.Usp_GetTDocumentoMMovimiento( dw_1.object.idtrans[1], 'S',gi_empresa, dw_1.object.idcentro[1], dw_1.object.idalma[1], ls_documento)
return ls_documento
end function

public function boolean of_verificar_datos_detalle ();double ld_nstock,ld_cant
//long ll_fila
String ls_item
integer li_fila,li_alma,li_item
decimal {3} ld_nstock2

For li_fila = 1 To dw_3.RowCount()
	li_item = dw_3.object.iditem[li_fila]
	li_alma = dw_3.object.idalma[li_fila]
	ld_cant = dw_3.object.ncant[li_fila]
	//-- Valores ceros y nulos
	If dw_3.GetItemDecimal(li_fila,'ncant') = 0 then// Or 	dw_3.GetItemDecimal(li_fila,'nprecio') = 0 Then 
		MessageBox('Advertencia','Error, Cantidad Digitada no Puede Ser Cero',stopsign!)
		Return False
	end if
		
	//-- Actualiza el numero de oc
	//idw_detalle.SetItem(ll_fila,'cc_ordcom', idw_ficha.object.cc_ordcom[1])
	ld_nstock = 0
	sqlca.usp_getstockmitemalma( li_item,li_alma,ld_nstock)
	if isnull(ld_nstock) then ld_nstock = 0
	if ld_cant > Truncate(ld_nstock,3) then
		dw_3.object.nstock[li_fila] =Truncate(ld_nstock,3)
		f_msg('El stock actual es menor a la cantidad de salida ',1); return false
	end if
Next

Return True

end function

public subroutine of_retrieve (long al_codigo);dw_1.retrieve(al_codigo);
dw_3.event ue_dropdowndw()
dw_3.retrieve(al_codigo); commit;
end subroutine

on u_cst_mmovimiento_salida.create
int iCurrent
call super::create
end on

on u_cst_mmovimiento_salida.destroy
call super::destroy
end on

event ue_parametros;integer li_param
s_parm 				lstr_parm
window w_to_open
istr_parm.auo_powerdock = uo_powerdock 
istr_parm.string_parm[1] = 'P'
li_param =istr_parm.integer_parm[2] 
//istr_parm.integer_parm[1] =1
//istr_parm.integer_parm[2] =1
//istr_parm.integer_parm[3] =9
OpenWithParm(w_to_open, istr_parm,is_window)	
lstr_parm=message.powerobjectparm
if lstr_parm.char_parm = '1' then
	istr_parm.integer_parm[1] =      lstr_parm.integer_parm[1]//centro o tienda
	istr_parm.integer_parm[2] =      lstr_parm.integer_parm[2]//almacen
	istr_parm.integer_parm[3] =      lstr_parm.integer_parm[3]//mes
	istr_parm.integer_parm[4] =      lstr_parm.integer_parm[4]//anio
	
//	dynamic of_setparam(lstr_parm.integer_parm[1],lstr_parm.integer_parm[2],lstr_parm.integer_parm[3])
	iuo_grillamain.dynamic of_setparam(lstr_parm.integer_parm[1],lstr_parm.integer_parm[2],lstr_parm.integer_parm[3],lstr_parm.integer_parm[4])
	iuo_grillamain.dynamic of_retrieve()
	event ue_ver_default( )
	//of_setparm( /*integer ai_parm1*/, /*integer ai_parm2*/, /*integer ai_parm3 */)
end if
end event

event ue_nuevo;call super::ue_nuevo;long ll_movimiento
string ls_transaccion
double ld_tica
datetime ldt_femision
ll_movimiento=0
sqlca.Usp_GetIdTablaINT(is_tabla,ll_movimiento)
dw_1.object.idmovimiento[1]=ll_movimiento
dw_1.object.idcentro[1]=istr_parm.integer_parm[1]
dw_1.object.idalma[1]=istr_parm.integer_parm[2]
dw_1.object.fdocumento[1] = today()
dw_1.object.idtrans[1] = 3
dw_1.object.fproceso[1] = today()
dw_1.object.tdocumento[1] = of_getTDocumento()
dw_1.object.iduser[1]=gs_iduser

ldt_femision =  datetime(date(today()),time('00:00:00'))
ld_tica = 0
sqlca.Usp_GetTipoCambio(ldt_femision,'V',ld_tica)
dw_1.object.ntipocambio[1]=ld_tica 


end event

event ue_agregar;integer li_row
if dw_1.accepttext( )= -1 Then Return 
If f_findrequired(dw_1) = -1 Then Return 
//dw_3.scrolltorow(dw_3.rowcount())
li_row =  dw_3.rowcount() 

//dw_3.setrowfocusindicator( hand!)


dw_3.Event ue_dropdowndw()	
dw_3.scrolltorow(dw_3.insertrow( 0))
dw_3.object.idmovimiento [dw_3.rowcount()]=dw_1.object.idmovimiento[1]
//dw_3.object.iditem [dw_3.rowcount()]=1
if li_row = 0 then
	dw_3.object.idindice [dw_3.rowcount()]=	1
else
	dw_3.object.idindice [dw_3.rowcount()]=	dw_3.object.idindice [li_row]+1
end if
//dw_3.GetChild("iditem", dwc);dwc.reset()
//gdc_mitem1.RowsCopy(gdc_mitem1.GetRow(), gdc_mitem1.RowCount(), Primary!, dwc, 1, Primary!)

is_alma = string(dw_1.object.idalma[1])
is_criterio="string(idalma)= '"+is_alma+"'"
f_filtrar_item('MITEMALMA',dw_3,dwc,dwc2,is_criterio)

dw_3.object.ncant [dw_3.rowcount()]=0
dw_3.object.idalma [dw_3.rowcount()]=dw_1.object.idalma[1]

//dw_3.object.nValorVta [dw_3.rowcount()]=1
//dw_3.object.nPrecioVta [dw_3.rowcount()]=1
//dw_3.object.bstat [dw_3.rowcount()]=1
end event

event ue_sumar;integer li_fila
double ld_preciobase,ld_totalDocu
ld_totalDocu = 0 
datetime ld_fecha
decimal{2} ld_igv 
ld_fecha =datetime(date(today()),time(now()))
ld_igv = 19
sqlca.Usp_GetIGV(ld_fecha,ld_igv)

for li_fila = 1 to dw_3.rowcount( )

	ld_preciobase = dw_3.Object.npreciobase[li_fila]
	dw_3.Object.nporc1[li_fila]=ld_igv
	dw_3.Object.nPrecioImpuesto1[li_fila]=ld_preciobase 
	//total inc igv
	dw_3.Object.ntotal[li_fila] = dw_3.Object.ncant[li_fila] * ld_preciobase
	dw_3.Object.nneto[li_fila] = dw_3.Object.ntotal[li_fila] / (1+(ld_igv/100))
	dw_3.Object.nimpuesto1[li_fila]=dw_3.Object.ntotal[li_fila] - dw_3.Object.nneto[li_fila]
	
	dw_3.Object.nprecioneto[li_fila]=dw_3.Object.nneto[li_fila] / dw_3.Object.ncant[li_fila]
	
	
	ld_totalDocu = ld_totalDocu  + dw_3.Object.ntotal[li_fila]
next

dw_1.Object.ntotal[1] =ld_totalDocu
end event

event ue_grabar_previo;long ll_movimiento
integer li_fila

CHOOSE CASE UPPER(is_button)
	case 'NUEVO'
		ll_movimiento=0
		sqlca.Usp_GetIdTablaINT(is_tabla,ll_movimiento)
		dw_1.object.idmovimiento  [1]=ll_movimiento
		dw_1.object.tdocumento    [1] = of_getTDocumento()
		dw_1.object.fproceso         [1] =today()
		il_documento = ll_movimiento
		event ue_sumar()
		for li_fila =1 to dw_3.rowcount( )
				dw_3.object.idindice  [li_fila] = li_fila
				dw_3.object.idmovimiento  [li_fila] = dw_1.object.idmovimiento  [1]
				dw_3.object.fproceso         [li_fila] =	dw_1.object.fproceso         [1] 
				dw_3.object.idcentro          [li_fila] =	dw_1.object.idcentro         [1] 
				dw_3.object.idalma            [li_fila] =	dw_1.object.idalma         [1] 
				dw_3.object.idtrans            [li_fila] =	dw_1.object.idtrans         [1] 
				dw_3.object.idmoneda        [li_fila] =	dw_1.object.idMoneda         [1] 
				
		next
	case 'EDITAR'
		dw_1.object.idUserModified         [1] =gs_iduser
		dw_1.object.fModified         [1] =today()
		for li_fila =1 to dw_3.rowcount( )
		
				dw_3.object.idmovimiento  [li_fila] = dw_1.object.idmovimiento  [1]
				dw_3.object.fproceso         [li_fila] =	dw_1.object.fproceso         [1] 
				dw_3.object.idcentro          [li_fila] =	dw_1.object.idcentro         [1] 
				dw_3.object.idalma            [li_fila] =	dw_1.object.idalma         [1] 
				dw_3.object.idtrans            [li_fila] =	dw_1.object.idtrans         [1] 
				dw_3.object.idmoneda        [li_fila] =	dw_1.object.idMoneda         [1] 
		next
		DELETE FROM MKARDEX WHERE IDMOVIDOCU = :il_codigo;
		
		
END CHOOSE


end event

event ue_grabar_otros;long ll_movimiento

CHOOSE CASE UPPER(is_button)
	case 'NUEVO'
			ll_movimiento = DW_1.OBJECT.idmovimiento[1]
			If sqlca.usp_addmkardex(ll_movimiento) <> 0  Then
				rollback USING SQLCA ;
				f_msj('Error al insertar al kardex',1)
				return FALSE
			End if
		case 'EDITAR'
			ll_movimiento = DW_1.OBJECT.idmovimiento[1]
			If sqlca.usp_updatemkardex(ll_movimiento) <> 0  Then
				rollback USING SQLCA ;
				f_msj('Error al update al kardex',1)
				return FALSE
			End if
			
	End Choose

return TRUE
end event

event ue_grabar_externo;long ll_movimiento = 0

ll_movimiento = dw_1.object.idmovimiento[1]

If sqlca.Usp_Anular_MKARDEX( 'K',ll_movimiento) <> 0  Then
	rollback USING SQLCA ;
	f_msj('Error al ANULAR al kardex',1)
	return -1
End if
of_retrieve(ll_movimiento)
dw_2.reset();dw_4.reset();
dw_1.RowsCopy(dw_1.GetRow(),dw_1.GetRow(), primary!, dw_2  , 1, Primary!)
dw_3.RowsCopy(1,dw_3.Rowcount(), primary!, dw_4, 1, Primary!)
dw_1.resetupdate();	dw_3.resetupdate(); 

COMMIT USING SQLCA;

iuo_grillamain.event dynamic ue_refrescar_row2(dw_2,dw_4,ii_row,is_button)
MessageBox('Informaci$$HEX1$$f300$$ENDHEX$$n','El Proceso de anulacion se Realizo Exitosamente',information!)

dw_4.GetChild("iditem", dwc);dwc.reset()
gdc_mitemalma1.RowsCopy(gdc_mitemalma1.GetRow(), gdc_mitemalma1.RowCount(), Primary!, dwc, 1, Primary!)
iuo_grillamain.event ue_activa_opc( false)
this.event ue_cambio_opc('Consultar')
this.event ue_settabtext( 'Consultar')

dw_1.reset();dw_3.reset( )
iuo_grillamain.event dynamic ue_activa_opc(false) 
iuo_grillamain.event dynamic ue_bloquear_refrescar(false) 
this.event ue_setdwc()
return 1
end event

event ue_anular;integer li_movimiento
string ls_stat
li_movimiento = dw_2.object.idmovimiento[1]

select tstat into :ls_stat from mmovimiento where idmovimiento = :li_movimiento;

if ls_Stat = 'N' then 
	f_msg('El registro ya esta anulado',1)
	return
end if


iuo_tabmantomain.event ue_setbutton(is_button)
iuo_tabmantomain.event	ue_set_ib_sw(true)

iuo_grillamain.event ue_activa_opc( true)
event ue_settabtext ('Anular '+ is_entidad)
event ue_cambio_opc('ANULAR')
is_columna = dw_1.describe('#'+string(1)+'.name')
is_tipocolumna = dw_1.describe(is_columna+'.coltype')	

dw_3.GetChild("iditem", dwc);dwc.reset()
gdc_mitemalma1.RowsCopy(gdc_mitemalma1.GetRow(), gdc_mitemalma1.RowCount(), Primary!, dwc, 1, Primary!)

if left(is_tipocolumna,4)='char' then
	 is_codigo =dw_2.object.data[1,1]
	 of_retrieve( is_codigo)	
elseif is_tipocolumna='int' then
	 ii_codigo =dw_2.object.data[1,1]
	 of_retrieve( ii_codigo)	
else
	il_codigo =dw_2.object.data[1,1]
	 of_retrieve( il_codigo)	
end if		





end event

event ue_editar;integer li_movimiento
string ls_stat
li_movimiento = dw_2.object.idmovimiento[1]

select tstat into :ls_stat from mmovimiento where idmovimiento = :li_movimiento;

if ls_Stat = 'N' then 
	f_msg('Registro anulado',1)
	return
end if


iuo_tabmantomain.event ue_setbutton(is_button)
iuo_tabmantomain.event	ue_set_ib_sw(true)

iuo_grillamain.event ue_activa_opc( true)
event ue_settabtext ('Editar '+ is_entidad)
event ue_cambio_opc('EDITAR')
is_columna = dw_1.describe('#'+string(1)+'.name')
is_tipocolumna = dw_1.describe(is_columna+'.coltype')	

dw_3.GetChild("iditem", dwc);dwc.reset()
gdc_mitem1.RowsCopy(gdc_mitem1.GetRow(), gdc_mitem1.RowCount(), Primary!, dwc, 1, Primary!)

if left(is_tipocolumna,4)='char' then
	 is_codigo =dw_2.object.data[1,1]
	 of_retrieve( is_codigo)	
elseif is_tipocolumna='int' then
	 ii_codigo =dw_2.object.data[1,1]
	 of_retrieve( ii_codigo)	
else
	il_codigo =dw_2.object.data[1,1]
	 of_retrieve( il_codigo)	
end if		
end event

event ue_cambio_opc;string ssas_button


choose case upper(as_button) 
	case 'NUEVO'
		of_proteger_dw( dw_3,0)
		uo_toolbarstrip.of_setvisible( 'Imprimir', false)
		uo_toolbarstrip.of_setvisible( 'Imprimir-Grabar', true)
		uo_toolbarstrip.visible = TRUE
		uo_toolbarstrip.of_setvisible( 'Editar', FALSE);
		uo_toolbarstrip.of_setvisible( 'Anular', FALSE)
		uo_toolbarstrip.of_setvisible( 'Grabar', TRUE)// ; uo_toolbarstrip.of_setenabled( 'Grabar', ab_ver)	
		uo_toolbarstrip.of_setvisible( 'Cancelar', TRUE)//;uo_toolbarstrip.of_setenabled( 'Cancelar', ab_ver)
		uo_toolbarstrip.of_setvisible( 'Agregar', TRUE)//; uo_toolbarstrip.of_setenabled( 'Agregar', lb_sw)
		uo_toolbarstrip.of_setvisible( 'Eliminar Fila', TRUE)//; uo_toolbarstrip.of_setenabled( 'Eliminar Fila', lb_sw)
		dw_1.visible = TRUE ; 		dw_3.visible = TRUE ; 	dw_2.visible =FALSE; 		dw_4.visible =FALSE
		dw_1.enabled = true ; dw_3.enabled=true
		event ue_settabtext( 'NUEVO')
	case 'EDITAR'
		uo_toolbarstrip.of_setvisible( 'Imprimir-Grabar', false)
		of_proteger_dw( dw_3,1)
		uo_toolbarstrip.visible = TRUE
		dw_1.enabled = true ; dw_3.enabled=true
		dw_1.visible = true ; 		dw_3.visible = true ; 	dw_2.visible =false; 		dw_4.visible =false
		uo_toolbarstrip.of_setvisible( 'Editar', false);
		uo_toolbarstrip.of_setvisible( 'Anular', false)
		uo_toolbarstrip.of_setvisible( 'Grabar', true) //; uo_toolbarstrip.of_setenabled( 'Grabar', ab_ver)	
		uo_toolbarstrip.of_setvisible( 'Cancelar', true)//;uo_toolbarstrip.of_setenabled( 'Cancelar', ab_ver)
		uo_toolbarstrip.of_setvisible( 'Agregar', false)//; uo_toolbarstrip.of_setenabled( 'Agregar', ab_ver)
		uo_toolbarstrip.of_setvisible( 'Eliminar Fila', false)//; uo_toolbarstrip.of_setenabled( 'Eliminar Fila', ab_ver)
		of_bloquear_columna( dw_3)
		event ue_settabtext( 'EDITAR')
	case 'ANULAR'
		uo_toolbarstrip.of_setvisible( 'Imprimir-Grabar', false)
		of_proteger_dw( dw_3,0)
		uo_toolbarstrip.visible = TRUE
		dw_1.enabled = false ; dw_3.enabled=false
		dw_1.visible = true ; 		dw_3.visible = true ; 	dw_2.visible =false; 		dw_4.visible =false
		uo_toolbarstrip.of_setvisible( 'Editar', false);
		uo_toolbarstrip.of_setvisible( 'Anular', false)
		uo_toolbarstrip.of_setvisible( 'Grabar', true) //; uo_toolbarstrip.of_setenabled( 'Grabar', ab_ver)	
		uo_toolbarstrip.of_setvisible( 'Cancelar', true)//;uo_toolbarstrip.of_setenabled( 'Cancelar', ab_ver)
		uo_toolbarstrip.of_setvisible( 'Agregar', false)//; uo_toolbarstrip.of_setenabled( 'Agregar', ab_ver)
		uo_toolbarstrip.of_setvisible( 'Eliminar Fila', false)//; uo_toolbarstrip.of_setenabled( 'Eliminar Fila', ab_ver)
	case 'CANCELAR'
		uo_toolbarstrip.of_setvisible( 'Imprimir', true)
		uo_toolbarstrip.of_setvisible( 'Imprimir-Grabar', false)
		dw_1.enabled = false ; dw_3.enabled=false
		uo_toolbarstrip.of_setvisible( 'Grabar', FALSE) //; uo_toolbarstrip.of_setenabled( 'Grabar', ab_ver)	
		dw_1.visible = FALSE ; 		dw_3.visible = FALSE ; 	dw_2.visible = TRUE; 		dw_4.visible =TRUE
		uo_toolbarstrip.of_setvisible( 'Cancelar', false)
		uo_toolbarstrip.of_setvisible( 'Editar', true);
		uo_toolbarstrip.of_setvisible( 'Anular', TRUE)
		uo_toolbarstrip.of_setvisible( 'Agregar', FALSE)//; uo_toolbarstrip.of_setenabled( 'Agregar', lb_sw)
		uo_toolbarstrip.of_setvisible( 'Eliminar Fila', FALSE)//; uo_toolbarstrip.of_setenabled( 'Eliminar Fila', lb_sw)
		event ue_settabtext( 'Consultar')
	CASE 'CONSULTAR'
		uo_toolbarstrip.of_setvisible( 'Imprimir', true)
		uo_toolbarstrip.of_setvisible( 'Imprimir-Grabar', false)
		dw_1.visible = FALSE ; 		dw_3.visible = FALSE ; 	dw_2.visible = TRUE; 		dw_4.visible =TRUE
		dw_1.enabled = false; dw_2.enabled = false
		uo_toolbarstrip.visible = TRUE
		uo_toolbarstrip.of_setvisible( 'Grabar', FALSE) //; uo_toolbarstrip.of_setenabled( 'Grabar', ab_ver)	
		dw_1.visible = FALSE ; 		dw_3.visible = FALSE ; 	dw_2.visible = TRUE; 		dw_4.visible =TRUE
		uo_toolbarstrip.of_setvisible( 'Cancelar', FALSE)
		uo_toolbarstrip.of_setvisible( 'Editar', true);
		uo_toolbarstrip.of_setvisible( 'Anular', true)
		uo_toolbarstrip.of_setvisible( 'Agregar', FALSE)//; uo_toolbarstrip.of_setenabled( 'Agregar', lb_sw)
		uo_toolbarstrip.of_setvisible( 'Eliminar Fila', FALSE)//; uo_toolbarstrip.of_setenabled( 'Eliminar Fila', lb_sw)
	CASE 'DEFAULT'
		dw_1.enabled= false ;	dw_1.visible = false ;		dw_2.visible = false ;		uo_1.visible = true
		uo_toolbarstrip.visible = false ;		st_titulo.visible = true ;		st_det1.visible = true
		event ue_settabtext( 'PRINCIPAL')
	case	else 
//		uo_toolbarstrip.of_setvisible( 'Grabar', lb_sw) //; uo_toolbarstrip.of_setenabled( 'Grabar', ab_ver)	
//		dw_1.visible = lb_sw ; 		dw_3.visible = lb_sw ; 	dw_2.visible = ab_ver; 		dw_4.visible =ab_ver
//		uo_toolbarstrip.of_setvisible( 'Cancelar', lb_sw)
//		uo_toolbarstrip.of_setvisible( 'Editar', ab_ver);
//		uo_toolbarstrip.of_setvisible( 'Anular', ab_ver)
//		uo_toolbarstrip.of_setvisible( 'Agregar', lb_sw)//; uo_toolbarstrip.of_setenabled( 'Agregar', lb_sw)
//		uo_toolbarstrip.of_setvisible( 'Eliminar Fila', lb_sw)//; uo_toolbarstrip.of_setenabled( 'Eliminar Fila', lb_sw)
end choose

end event

event ue_imprimir;call super::ue_imprimir;int ll_iddocumento
//ll_iddocumento = dw_1.object
decimal {2} ld_cantPrint = 15.00

dw_5.dataobject  = 'd_Usp_PrintMMovimiento'
dw_5.settransobject( sqlca)
dw_5.retrieve(il_documento,ld_cantPrint)
dw_5.Object.DataWindow.Print.Paper.Size = 256
dw_5.Object.DataWindow.Print.CustomPage.Length = 140
dw_5.Object.DataWindow.Print.CustomPage.Width = 226  //7 inches
dw_5.print();commit;


end event

event ue_grabar_pos;call super::ue_grabar_pos;if ib_printgrabar then
	this.event ue_print()
end if

this.event ue_nuevo()
end event

event constructor;call super::constructor;is_alma = string(istr_parm.integer_parm[2])
is_criterio="string(idalma)= '"+is_alma+"'"
end event

type dw_5 from u_cst_mantocabedet`dw_5 within u_cst_mmovimiento_salida
end type

type dw_4 from u_cst_mantocabedet`dw_4 within u_cst_mmovimiento_salida
integer y = 792
integer width = 3077
integer height = 1348
string dataobject = "d_mmovimientod_tabular"
end type

type dw_3 from u_cst_mantocabedet`dw_3 within u_cst_mmovimiento_salida
integer y = 788
integer height = 1356
end type

event dw_3::itemchanged;call super::itemchanged;DataWindowChild 	LdwChild
string ls_descripcion, ls_orden, ls_artic
long ll_registro
decimal{4} ld_fm_precio 
decimal{2} ld_fm_dcto1 , ld_fm_dcto2 , ld_fm_dcto3 , ld_fm_dcto4
double ld_cant,ld_nstock
integer li_item	,li_alma
Choose Case dwo.name
	Case 'iditem'
		//-- Verifica si es valido
		If Trim(data) = '' Or IsNull(data) Then
			Messagebox('Sistema','Error, Digite un C$$HEX1$$f300$$ENDHEX$$digo Valido', StopSign!)
			Return 1
		End If
		li_item = integer (data)
		li_alma = Object.idalma[ row ]
		//-- Recupera las unidades de medida
		This.GetChild('idunid',LdwChild)
		LdwChild.SetTransObject(SQLCA)
		LdwChild.Retrieve(li_item,'D')
		if ldwChild.RowCount() <> 0 then
			Object.idunid[ row ] = ldwChild.GetItemString( 1 ,1)
		end if
		
		sqlca.usp_getstockmitemalma( li_item, li_alma, ld_nstock)
		Object.nstock[ row ] = round(ld_nstock,3)
//		//-- Verifica si ya fue ingresado
//		If find('cc_servic=~''+data+'~'',1, RowCount()) >0 Then
//			Messagebox('Sistema','El Servicio ya Fue Registrado Anteriormente, Digite uno Valido', StopSign!)
//			Return 1
//		End If
Case 'idunid'
		//-- Si es valido
		If Trim(data) = '' Or IsNull(data) Then
			Messagebox('Sistema','Error, Digite un C$$HEX1$$f300$$ENDHEX$$digo Valido', StopSign!)
			Return 1
		End If

//		//-- Verifica si existe
//		ls_descripcion = Space(40)
//		SQLCA.sp_cat_mat_unidad_medida(data,ls_descripcion)
//		If Trim(ls_descripcion) = '' Then
//			Messagebox('Sistema','Error, C$$HEX1$$f300$$ENDHEX$$digo No Registrado, Digite uno Valido', StopSign!)
//			Return 1
//		End If
//
//		//-- Verifica las unidades de destino
//		ll_registro = 0
//		SQLCA.sp_alm_obt_aumalter(This.GetItemString(row,'cc_artic'),data,ll_registro)
//		If ll_registro = 0 Then
//			Messagebox('Sistema','Error, Unidad de Medida no Asignada al Art$$HEX1$$ed00$$ENDHEX$$culo, Digite Uno Valido', StopSign!)
//			Return 1
//		End If
	case 'ncant'
		if(double(data))> 0  then post event ue_sumar()
	case 'npreciobase'
		post event ue_sumar()
//		  this.object.ntotal[row] = this.getitemDecimal( row,'ncant') *  double (data)
//	case ''
end choose
end event

event dw_3::ue_dropdowndw;call super::ue_dropdowndw;DataWindowChild 	LdwChild

This.GetChild('idunid',LdwChild)
LdwChild.SetTransObject(SQLCA)
LdwChild.InsertRow(0)

Return 1

end event

event dw_3::rowfocuschanged;call super::rowfocuschanged;//-- Recupera las unidades de medida
If currentRow<=0 Then Return
integer li_item 
datawindowchild ldwc_1
this.getchild('idunid',ldwc_1);ldwc_1.reset()
ldwc_1.settransobject(sqlca)
li_item  = Object.iditem[currentrow]
if isnull(li_item ) then li_item =1
ldwc_1.Retrieve(li_item,'D')
end event

type st_det2 from u_cst_mantocabedet`st_det2 within u_cst_mmovimiento_salida
end type

type st_det1 from u_cst_mantocabedet`st_det1 within u_cst_mmovimiento_salida
end type

type st_titulo from u_cst_mantocabedet`st_titulo within u_cst_mmovimiento_salida
end type

type dw_2 from u_cst_mantocabedet`dw_2 within u_cst_mmovimiento_salida
integer x = 0
integer y = 104
integer width = 3086
integer height = 684
string dataobject = "d_mmovimiento_salida_free"
end type

type uo_toolbarstrip from u_cst_mantocabedet`uo_toolbarstrip within u_cst_mmovimiento_salida
end type

event uo_toolbarstrip::constructor;this.of_AddItem('Grabar', 'Save!')
this.of_AddItem('Imprimir-Grabar', 'Print!')
this.of_AddItem('Editar', '..\IMG\ICO\edit.ico')
this.of_AddItem('Anular', '..\IMG\ICO\Error.ico')
this.of_AddItem('Agregar', 'Insert5!')
this.of_AddItem('Eliminar Fila', 'DeleteRow!')
this.of_AddItem('Cancelar', 'Undo!')
this.of_AddItem('Imprimir', 'Print!')

//opciones en estado invisible
this.of_setvisible( 'Grabar', false)
this.of_setvisible( 'Agregar', false)
this.of_setvisible( 'Eliminar Fila', false)
this.of_setvisible( 'Cancelar', false)
this.of_setvisible('Imprimir-Grabar', false)
this.of_setvisible('Imprimir', false)
//esto es para mostar los textos
this.of_DisplayText(true)




end event

event uo_toolbarstrip::ue_buttonclicked;string ls_columna,ls_tipo,ls_codigo
integer li_codigo
long ll_codigo,ll_opc

choose case upper(as_button)
	case 'IMPRIMIR'	
		il_documento = dw_2.object.data [1,1]
		event ue_print()
//		update mmovmiento set bimpreso = 1 where iddocumento = :il_documento;
//		commit;
//		dw_1.retrieve(il_documento)
//		dw_2.object.data=dw_1.object.data
		commit;
		
		//event ue_copy_fila(dw_2, 1, 1)
	case 'IMPRIMIR-GRABAR'	
		ib_printGrabar = true
		event  ue_grabar( )
	case 'ANULAR'
		is_button = as_button
		event ue_anular()
	case 'ELIMINAR FILA'
		EVENT ue_eliminar_detalle()
	case 'AGREGAR'
		//FOR ll_codigo = 1 to 10000
			event ue_agregar()
		//next
	case 'EDITAR'
			is_button = as_button
			event ue_editar()
	case 'GRABAR'
		event  ue_grabar( )
	case 'CANCELAR'
		
	   if upper(is_button) ='NUEVO' then 
			is_button ='DEFAULT'
		ELSE
			is_button ='CANCELAR'
	   end if	
	  // is_button = as_button
       event ue_cancelar()
	//  event ue_settabtext( 'PRINCIPAL')	
		//	iuo_tab.event dynamic ue_enabled_object(true)
		//	case 'SALIR'
		//	uo_powerdock.of_closedocument(uo_powerdock.of_getactiveobject( ))
END CHOOSE
end event

type dw_1 from u_cst_mantocabedet`dw_1 within u_cst_mmovimiento_salida
integer height = 684
end type

event dw_1::itemchanged;call super::itemchanged;
choose case dwo.name
	case 'idtrans'
		dw_1.object.tdocumento[1] = of_getTDocumento()
end choose
end event

type uo_1 from u_cst_mantocabedet`uo_1 within u_cst_mmovimiento_salida
end type

